export function createBroadcastChannel() {
  const bd = new BroadcastChannel("broadcast");

  // 监听广播消息
  bd.onmessage = function (event) {
    // console.log("React 收到广播消息：", event.data);
    // 处理接收到的消息
  };

  // 发送广播消息
  function sendBroadcastMessage(message) {
    bd.postMessage(message);
  }

  // 关闭广播通道
  function closeBroadcastChannel() {
    bd.close();
  }
  return {
    sendBroadcastMessage,
    closeBroadcastChannel,
  };
}
